package com.example.applicationcontextaware.controller;

import com.example.applicationcontextaware.bean.TestEntity;
import com.example.applicationcontextaware.event.TestEvent;
import com.example.applicationcontextaware.util.SpringContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * @description:
 * @author: luojm
 * @create: 2020-10-10 17:30
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {
    @GetMapping("/hello")
    public Integer hello() {
        SpringContextHolder.publishEvent(new TestEvent(new TestEntity() {{
            setLocalDateTime(LocalDateTime.now());
        }}));
        return 1;
    }
}
